﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using PMSA.Framework.Database;

/// <summary>
/// Summary description for CNewsFacade
/// </summary>
public class CNewsFacade
{
    private NewsDAL db = new NewsDAL();
    public IList<News> List(int pageIndex, int pageMax, int groupnewsid, int isActive)
    {
        IList<News> list = null;
        DataSet ds = new DataSet();
        ds = db.List(pageIndex, pageMax, groupnewsid, isActive);
        if (ds != null && ds.Tables.Count > 0)
        {
            list = CDb.MapList<News>(ds.Tables[0]);
        }
        return list;
    }
    public News Detail(int Newsid)
    {
        DataSet ds = new DataSet();
        ds = db.Detail(Newsid);
        News obj = CDb.Map<News>(ds.Tables[0]);
        return obj;
    }
    public News Update(int newsid, string title, string thumbnail, string content, string description, int groupNewsId, int status, int isActive)
    {
        DataSet ds = new DataSet();
        ds = db.Update(newsid, title, thumbnail, content, description, groupNewsId, status, isActive);
        News obj = CDb.Map<News>(ds.Tables[0]);
        return obj;
    }
    public News Insert(string title, string thumbnail, string content, string description, int userid, int groupNewsId, int status, int isActive)
    {
        DataSet ds = new DataSet();
        ds = db.Insert(title, thumbnail, content, description, userid, groupNewsId, status, isActive);
        News obj = CDb.Map<News>(ds.Tables[0]);
        return obj;
    }
    public News UpdateStatusActive(int Newsid, int Status)
    {
        DataSet ds = new DataSet();
        ds = db.UpdateStatusActive(Newsid, Status);
        News obj = CDb.Map<News>(ds.Tables[0]);
        return obj;
    }
}